//
//  ImagePickerViewController.m
//  Component
//
//  Created by Andy_chen on 16/4/6.
//  Copyright © 2016年 Andycchen. All rights reserved.
//

#import "ImagePickerViewController.h"
#import "UIView+SDAutoLayout.h"
#import <Photos/Photos.h>
#import "WXImagePickerController.h"
#import "WXAlbumPickerController.h"

@interface ImagePickerViewController ()<WXImagePickerControllerDelegate>
@property (nonatomic, strong) UIButton *pushButton;

@end

@implementation ImagePickerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self pushButton];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)choseAlbum {
    
    WXAlbumPickerController *albumController = [[UIStoryboard storyboardWithName:@"Picker" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
    WXImagePickerController *wxPicker = [[WXImagePickerController alloc]initWithRootViewController:albumController];
    wxPicker.maximumImagesCount = 9;
    [self presentViewController:wxPicker animated:YES completion:nil];
}

#pragma mark - WXImagePickerControllerDelegate
- (void)wxImagePickerController:(WXImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info {
    
}

- (void)wxImagePickerControllerDidCancel:(WXImagePickerController *)picker {
    
}

#pragma mark - getters and setters
- (UIButton *)pushButton {
    
    if (!_pushButton) {
        _pushButton = [[UIButton alloc]initWithFrame:CGRectZero];
        _pushButton.backgroundColor = [UIColor redColor];
        [_pushButton addTarget:self action:@selector(choseAlbum) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:_pushButton];
        
        _pushButton.sd_layout
        .centerXEqualToView(self.view)
        .centerYEqualToView(self.view)
        .widthIs(100)
        .heightIs(50);
    }
    return _pushButton;
}


@end
